package net.khoroshev.wschat.service.auth;

import net.khoroshev.wschat.model.entity.AuthUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.UserDetailsManager;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * Created by: vfirstov
 * Date: 16.11.13
 * Time: 21:04
 *
 */

@Service
public class AuthService {

    @Autowired
    private UserDetailsManager userDetailsService;


    public void addUser(final String firstName,
                        final String lastName,
                        final String email,
                        final String password) {

        AuthUser user = new AuthUser(firstName, lastName, email, password, Authorities.USER_AUTHORITIES);

        userDetailsService.createUser(user);
    }

    public boolean userExists(String value) {
        //todo implemented next
        //userDetailsService.userExists(value);
        return false;
    }


}
